package symboltable;

import java.util.*;

public class SymbolTable {

    private HashMap<Symbol, ClassTable> symbolTable;
    private HashMap<Symbol, Symbol> heritagesTable;

    public SymbolTable() {
        symbolTable = new HashMap<>();
        heritagesTable = new HashMap<>();
    }

    public ClassTable addClass(Symbol identifier) {
        if (!symbolTable.containsKey(identifier)) {
            ClassTable classTable = new ClassTable();
            classTable.setIdentifier(identifier.toString());
            symbolTable.put(identifier, classTable);
            return classTable;
        } else {
            return null;
        }

    }

    public ClassTable getClass(Symbol name) {
        return symbolTable.get(name);
    }

    public void addHeritage(Symbol class1, Symbol class2) {
        heritagesTable.put(class1, class2);
    }

    public HashMap<Symbol, ClassTable> getSymbolTable() {
        return symbolTable;
    }

    public void setSymbolTable(HashMap<Symbol, ClassTable> symbolTable) {
        this.symbolTable = symbolTable;
    }

    public HashMap<Symbol, Symbol> getHeritages() {
        return heritagesTable;
    }

    public void setHeritages(HashMap<Symbol, Symbol> heritagesTable) {
        this.heritagesTable = heritagesTable;
    }
}
